package com.tiny.mirror.service.product.domain;

import com.tiny.mirror.service.product.domain.ability.Ability;
import com.tiny.mirror.service.product.domain.app.App;
import com.tiny.mirror.service.product.domain.platform.Platform;
import com.tiny.mirror.service.product.infrastructure.entity.db.AbilityEntity;
import com.tiny.mirror.service.product.infrastructure.entity.db.AppEntity;
import com.tiny.mirror.service.product.infrastructure.entity.db.PlatformEntity;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

/**
 * @Author: lanpai
 * @Description:
 * @Date: Create in 2023/9/24
 */
@SuppressWarnings("CPD-START")
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class DomainFactory {

  public static App convertToApp(AppEntity item) {
    if (item == null) {
      return null;
    }
    App result = new App();
    result.setId(item.getId());
    result.setName(item.getName());
    result.setPrice(item.getPrice());
    result.setParams(item.getParams());
    result.setType(item.getType());
    result.setStatus(item.getStatus());
    result.setOrderNum(item.getOrderNum());
    return result;
  }

  public static AppEntity convertToAppEntity(App item) {
    if (item == null) {
      return null;
    }
    AppEntity result = new AppEntity();
    if (item.getId() > 0) {
      result.setId(item.getId());
    }
    result.setName(item.getName());
    result.setPrice(item.getPrice());
    result.setParams(item.getParams());
    result.setType(item.getType());
    result.setStatus(item.getStatus());
    result.setOrderNum(item.getOrderNum());
    return result;
  }

  public static Platform convertToPlatform(PlatformEntity item) {
    if (item == null) {
      return null;
    }
    Platform result = new Platform();
    result.setId(item.getId());
    result.setAppId(item.getAppId());
    result.setName(item.getName());
    result.setParams(item.getParams());
    result.setType(item.getType());
    result.setStatus(item.getStatus());
    result.setOrderNum(item.getOrderNum());
    return result;
  }

  public static PlatformEntity convertToPlatformEntity(Platform item) {
    if (item == null) {
      return null;
    }
    PlatformEntity result = new PlatformEntity();
    if (item.getId() > 0) {
      result.setId(item.getId());
    }
    result.setAppId(item.getAppId());
    result.setName(item.getName());
    result.setParams(item.getParams());
    result.setType(item.getType());
    result.setStatus(item.getStatus());
    result.setOrderNum(item.getOrderNum());
    return result;
  }

  public static Ability convertToAbility(AbilityEntity item) {
    if (item == null) {
      return null;
    }
    Ability result = new Ability();
    result.setId(item.getId());
    result.setName(item.getName());
    result.setParams(item.getParams());
    result.setType(item.getType());
    result.setStatus(item.getStatus());
    result.setOrderNum(item.getOrderNum());
    return result;
  }

  public static AbilityEntity convertToAbilityEntity(Ability item) {
    if (item == null) {
      return null;
    }
    AbilityEntity result = new AbilityEntity();
    if (item.getId() > 0) {
      result.setId(item.getId());
    }
    result.setName(item.getName());
    result.setParams(item.getParams());
    result.setType(item.getType());
    result.setStatus(item.getStatus());
    result.setOrderNum(item.getOrderNum());
    return result;
  }
}
